Stinga SG VersionInfo

Previous PageUp PageNext Page

Enumerate Files

© 1998 by Stinga.


This VBScript enumerates files from the system directory and prints version information for files that have it. You will need WSH to run this example.

' Create objects
set VerInfo = WScript.CreateObject("sgVersionInfo.VersionInfo")
Set fs = WScript.CreateObject("Scripting.FileSystemObject")
Set foldr = fs.GetFolder(WScript.Path)

On Error Resume Next
Dim sMsg
Dim vbCrLf
vbCrLf = Chr(13) + Chr(10)

' Are we running from command line
Dim bFromCmdLine
bFromCmdLine = false
if InStrRev(UCase(WScript.FullName), "CSCRIPT") then bFromCmdLine = true

' Scan all files in the folder
For Each File In foldr.Files

    ' Try to get version info for current file
    VerInfo.Path = File.Path
    if Err.Number = 0 then
        ' No error. Display version info if file contains any
        if VerInfo.InfoExist then
            sMsg = UCase(file.Name) + " - " + VerInfo.FileDescription + vbCrLf
            sMsg = sMsg + "Product Name: " + VerInfo.ProductName + vbCrLf
            sMsg = sMsg + "File Version: " + VerInfo.FileVersion + vbCrLf
            sMsg = sMsg + "Product Version: " + VerInfo.ProductVersion + vbCrLf
            sMsg = sMsg + "Company Name: " + VerInfo.CompanyName + vbCrLf
            sMsg = sMsg + "Internal Name: " + VerInfo.InternalName + vbCrLf
            sMsg = sMsg + "Original Filename: " + VerInfo.OriginalFilename + vbCrLf
            sMsg = sMsg + "Private Build: " + VerInfo.PrivateBuild + vbCrLf
            sMsg = sMsg + "Special Build: " + VerInfo.SpecialBuild + vbCrLf
            sMsg = sMsg + "Legal Copyright: " + VerInfo.LegalCopyright + vbCrLf
            sMsg = sMsg + "Legal Trademarks: " + _
                  VerInfo.GetValue("StringFileInfo", "LegalTrademarks") + vbCrLf
            sMsg = sMsg + "Language: " + VerInfo.LanguageName + vbCrLf
            sMsg = sMsg + "Comments: " + VerInfo.Comments + vbCrLf
            sMsg = sMsg + "OS: " + VerInfo.FileOSString + vbCrLf

            if bFromCmdLine then
                WScript.Echo sMsg
            else
                rc = MsgBox(sMsg, 1)
                if rc = 2 then WScript.Quit(0)
            end if
        end if
    else
        ' Somethig went wrong
        sMsg = file.Name + ": " + Err.Decription
        if bFromCmdLine then
            WScript.Echo sMsg
            MsgBox file.Name + ": " + Err.Decription
        else
            MsgBox sMsg
        end if
        Err.Clear
    end if
next

set VerInfo = nothing
Set fs = nothing
Set foldr = nothing




You can find several sample programs and scripts in the Samples subfolder of the SGVersionInfo installation folder.

 

 

Previous PageUp PageNext Page